package com.bootdo.appsystem.service.impl;

import com.bootdo.app.utils.redis.AppRedisUtil;
import com.bootdo.app.utils.returnresponse.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bootdo.appsystem.dao.ProductscategoryDao;
import com.bootdo.appsystem.domain.ProductscategoryDO;
import com.bootdo.appsystem.service.ProductscategoryService;



@Service
public class ProductscategoryServiceImpl implements ProductscategoryService {
	@Autowired
	private ProductscategoryDao productscategoryDao;
	
	@Override
	public ProductscategoryDO get(Integer procetid){
		return productscategoryDao.get(procetid);
	}
	
	@Override
	public List<ProductscategoryDO> list(Map<String, Object> map){
		return productscategoryDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return productscategoryDao.count(map);
	}
	
	@Override
	public int save(ProductscategoryDO productscategory){
		return productscategoryDao.save(productscategory);
	}
	
	@Override
	public int update(ProductscategoryDO productscategory){
		return productscategoryDao.update(productscategory);
	}
	
	@Override
	public int remove(Integer procetid){
		return productscategoryDao.remove(procetid);
	}
	
	@Override
	public int batchRemove(Integer[] procetids){
		return productscategoryDao.batchRemove(procetids);
	}

	@Override
	public ServerResponse creatCategory(Integer topid) {
		List<ProductscategoryDO> productscategoryDOList = null;
		try {
			HashMap<String , Object> map = new HashMap<>();
			if (topid == 0) {
				map.put("topid" , "0" );
			}else {
				map.put("topid" , topid );
			}
			productscategoryDOList = this.list(map);
		}catch (RuntimeException e){
			e.printStackTrace();
			return ServerResponse.createByError();
		}
		return ServerResponse.createBySuccess(productscategoryDOList);
	}

}
